package com.itcast.mapper;

import com.itcast.pojo.Clazz;
import com.itcast.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface ClazzMapper {

    List<Clazz> getClazzByPage(String name, LocalDate beginDate, LocalDate endDate);

    void deleteClazzById(Integer id);

    void addClazz(Clazz clazz);

    @Select("select c.id,c.name, room, begin_date, end_date, master_id, subject, c.create_time, c.update_time,e.name as master_name " +
            "from clazz c LEFT JOIN emp e on c.master_id = e.id where c.id = #{id}")
    Clazz findClazzById(Integer id);

    @Update("update clazz set name = #{name}, room = #{room}, begin_date = #{beginDate}, " +
            "end_date = #{endDate}, master_id = #{masterId}, subject = #{subject}, update_time = #{updateTime} where id = #{id}")
    void updateClazzById(Clazz clazz);
    @Select("select * from clazz")
    List<Clazz> findAllClazz();
}
